import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
class SpinDemo(QWidget):
    def __init__(self,parent=None):
        super(SpinDemo,self).__init__(parent)
        self.setWindowTitle("计数器")
        self.resize(300,100)
        layout=QVBoxLayout()
        self.l1=QLabel("current vale:")
        self.l1.setAlignment(Qt.AlignCenter)
        layout.addWidget(self.l1)
        self.sp=QSpinBox()
        layout.addWidget(self.sp)
        self.sp.valueChanged.connect(self.valuechanged)
        self.setLayout(layout)
        
    def valuechanged(self):
        self.l1.setText("current value:"+str(self.sp.value()))
if __name__ == '__main__':
    app=QApplication(sys.argv)
    win=SpinDemo()
    win.show()
    sys.exit(app.exec_())